<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    /* 双色球1 */
    * {
        margin: 0px auto;
        text-align: center;
    }

    body {
        padding-top: 30px;
    }

    .qiu {
        width: 40px;
        height: 40px;
        background: red;
        border: 1px solid #333;
        border-radius: 25px;
        float: left;
        text-align: center;
        line-height: 40px;
        color: white;
        font-size: 21px;
        margin-left: 10px;
    }

    #qiu {
        display: inline-block;
    }

    .btn {
        display: inline-block;
    }

    button {
        width: 60px;
        height: 40px;
        float: left;
        margin-left: 15px;
    }
</style>

<body>
    <!-- 双色球 -->
    <div id='qiu'>

    </div>
    <div class="btn">
        <button onclick="start()">开始</button>
        <button onclick="stop()">停止</button>
    </div>



</body>
<script>
    //双色球
    var arr = [], startS
    //产生6个1-33的随机数
    function fun() {
        let num = randNum(1, 34)
        if (arr.indexOf(num) == -1) {
            arr.push(num)
        }
        if (arr.length < 6) {
            fun()
        }
    }
    //指定范围随机数
    function randNum(min, max) {
        return Math.floor(Math.random() * (max - min) + 1) + min;
    }
    //定时器开始
    function start() {
        clearInterval(startS)
        startS = setInterval("ssq()", 10)
    }
    //定时器停止
    function stop() {
        clearInterval(startS)
    }
    //双色球
    function ssq() {
        arr = []
        fun()
        arr.push(randNum(1, 16))
        var str = ''
        for (i in arr) {
            if (i == arr.length - 1) {
                str += "<div class='qiu' style='background:blue;'>" + arr[i] + "</div>"
            } else {
                str += "<div class='qiu'>" + arr[i] + "</div>"
            }
        }
        document.getElementById('qiu').innerHTML = str
    }
    ssq()




</script>

</html>